package com.application.Activity;

import com.application.Network.Protocol;
import com.application.outdoor.InvoikeServices.HeThongInvoike;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class od_TraLoiVaoNhomActivity extends Activity {
	Button btnDongY, btnTuChoi;
	TextView txtNguoiDung,txtNoiDung;
	public static int idNhom;
	public static int idTinNhan;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.od_tra_loi_vao_nhom_activity);
        btnDongY=(Button)findViewById(R.id.btnDongY);
        btnTuChoi=(Button)findViewById(R.id.btnTuChoi);
        txtNguoiDung=(TextView)findViewById(R.id.txtNguoiDung);
        txtNoiDung=(TextView)findViewById(R.id.txtNoiDung);
        btnDongY.setOnClickListener(new OnClickListener() {
			

			@Override
			public void onClick(View v) {
				try {
					new HeThongInvoike().dongYVaoNhom(idNhom, idTinNhan,
							CommonUtilities.nguoiDung.getTenDangNhap());
				} catch (Exception e) {
					Log.e(Protocol.TAG,"HeThongInvoike().dongYVaoNhom "+e.getMessage());
					e.printStackTrace();
				}
				finish();
			}
		});
        btnTuChoi.setOnClickListener(new OnClickListener() {
			
			

			@Override
			public void onClick(View v) {
				try {
					new HeThongInvoike().capNhatDaDocTinNhan(idTinNhan);
				} catch (Exception e) {
					Log.e(Protocol.TAG,"HeThongInvoike().capNhatDaDocTinNhan "+e.getMessage());
					e.printStackTrace();
				}
				finish();
			}
		});
        
        Intent data=getIntent();
        String nguoiGui=data.getStringExtra(Protocol.NGUOI_GUI);
        String noiDung=data.getStringExtra(Protocol.NOI_DUNG);
        idTinNhan=Integer.parseInt(data.getStringExtra(Protocol.ID));
        
        String[] m = noiDung.split(";");
		idNhom = Integer.parseInt(m[0]);
        txtNguoiDung.setText(nguoiGui);
        txtNoiDung.setText(" mời bạn vào nhóm "+ m[1]);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.od_tra_loi_vao_nhom_activity, menu);
        return true;
    }

    
}
